package com.review.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.review.common.annotation.Log;
import com.review.common.core.controller.BaseController;
import com.review.common.core.domain.AjaxResult;
import com.review.common.enums.BusinessType;
import com.review.project.domain.ReviewNorm;
import com.review.project.service.IReviewNormService;
import com.review.common.utils.poi.ExcelUtil;
import com.review.common.core.page.TableDataInfo;

/**
 * 评分指标Controller
 * 
 * @author evan
 * @date 2022-04-29
 */
@RestController
@RequestMapping("/project/norm")
public class ReviewNormController extends BaseController
{
    @Autowired
    private IReviewNormService reviewNormService;

    /**
     * 查询评分指标列表
     */
    @PreAuthorize("@ss.hasPermi('project:norm:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReviewNorm reviewNorm)
    {
        startPage();
        List<ReviewNorm> list = reviewNormService.selectReviewNormList(reviewNorm);
        return getDataTable(list);
    }

    /**
     * 导出评分指标列表
     */
    @PreAuthorize("@ss.hasPermi('project:norm:export')")
    @Log(title = "评分指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReviewNorm reviewNorm)
    {
        List<ReviewNorm> list = reviewNormService.selectReviewNormList(reviewNorm);
        ExcelUtil<ReviewNorm> util = new ExcelUtil<ReviewNorm>(ReviewNorm.class);
        util.exportExcel(response, list, "评分指标数据");
    }

    /**
     * 获取评分指标详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:norm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(reviewNormService.selectReviewNormById(id));
    }

    /**
     * 新增评分指标
     */
    @PreAuthorize("@ss.hasPermi('project:norm:add')")
    @Log(title = "评分指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReviewNorm reviewNorm)
    {
        return toAjax(reviewNormService.insertReviewNorm(reviewNorm));
    }

    /**
     * 修改评分指标
     */
    @PreAuthorize("@ss.hasPermi('project:norm:edit')")
    @Log(title = "评分指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReviewNorm reviewNorm)
    {
        return toAjax(reviewNormService.updateReviewNorm(reviewNorm));
    }

    /**
     * 删除评分指标
     */
    @PreAuthorize("@ss.hasPermi('project:norm:remove')")
    @Log(title = "评分指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(reviewNormService.deleteReviewNormByIds(ids));
    }
}
